package com.autumn.auth.server.controllers.api;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

	@GetMapping("/getUserInfo")	
	public Long userInfo() {
		//ExceptionUtils.throwUserFriendlyException("错了");
		return 50L;
	}
	
	/**
	 * 返回当前用户的信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "/principal", method = RequestMethod.GET)
	public Object getPrincipal() {
		Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return principal;
	}
}
